// 这是专门用来书写用户的api
import request from "@/utils/request";

// 限制登录的参数
export interface LoginUserType {
    username: string,
    password: string
}

// 限制登录请求返回的promise的返回值
export interface returnLoginType {
    token: string
}

// 1- 用户登录请求
export const reqPostLoginAsync = (userInfo: LoginUserType) => {
    return request.post<null, returnLoginType>(`/admin/acl/index/login`, userInfo)
}

// 2- 用户退出登录请求
export const reqPostLoginOutAsync = () => {
    return request.post<null, null>(`/admin/acl/index/logout`)
}

// 限制获取用户信息请求返回的promise的返回值
export interface UserInfoType {
    routes: string[],
    buttons: string[],
    roles: string[],
    name: string,
    avatar: string
}

// 3- 获取用户信息的请求
export const reqGetUserInfoAsync = () => {
    return request.get<null, UserInfoType>(`/admin/acl/index/info`)
}